package com.example.xmind2testcase.service;

import com.example.xmind2testcase.mapper.FileMapper;
import com.example.xmind2testcase.pojo.File;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FileServiceImpl implements FileService{

    @Autowired
    private FileMapper fileMapper;

    @Override
    public List<File> queryFile(Long projectId) {
        return fileMapper.queryFile(projectId);
    }

    @Override
    public File addFile(File file) {
        List<File> files = fileMapper.queryFileByFile(file);
        if(files.size()>0){
            System.out.println("存在同名文件");
        }
        fileMapper.addFile(file);
        List<File> files1 = fileMapper.queryFileByFile(file);
        System.out.println(files1);

        return files1.get(0);
    }
}
